<template>
	<el-drawer title="资产详情" v-model="visible" :size="800" destroy-on-close @closed="$emit('closed')">
		<el-container v-loading="loading">
			<el-main>
				<el-form>
					<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="left">
						<el-row :gutter="24">
							<el-col :lg="12">
								<el-form-item label="排序号" prop="sortNo">
									{{form.sortNo}}
								</el-form-item>
							</el-col>
							<el-col :lg="12">
								<el-form-item label="物资编号" prop="assetsCode">
									{{form.assetsCode}}
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="24">
							<el-col :lg="12">
								<el-form-item label="资产名称" prop="assetsName">
									{{form.assetsName}}
								</el-form-item>
							</el-col>
							<el-col :lg="12">
								<el-form-item label="所属分类" prop="sortId">
									{{form.sortName}}
								</el-form-item>
							</el-col>
						</el-row>

						<el-row :gutter="24">
							<el-col :lg="12">
								<el-form-item label="使用部门" prop="ownDept">
									{{form.ownDeptName}}
								</el-form-item>
							</el-col>
							<el-col :lg="12">
								<el-form-item label="存放仓库" prop="storageId">
									{{form.storageName}}
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="24">
							<el-col :lg="12">
								<el-form-item label="品牌" prop="brand">
									{{form.brand}}
								</el-form-item>
							</el-col>
							<el-col :lg="12">
								<el-form-item label="型号" prop="model">
									{{form.model}}
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="24">
							<el-col :lg="12">
								<el-form-item label="采购价格" prop="purchasePrice">
									{{form.purchasePrice}}/{{form.unitName}}
								</el-form-item>
							</el-col>
							<el-col :lg="12">
								<el-form-item label="采购时间" prop="purchaseTime">
									{{form.purchaseTime}}
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="24">
							<el-col :lg="12">
								<el-form-item label="折旧方式" prop="depreciation">
									{{this.getDepreciation(form.depreciation)}}
								</el-form-item>
							</el-col>
							<el-col :lg="12">
								<el-form-item label="当前状态" prop="status">
									<el-tag type="success" effect="dark" v-if="form.status=='0'">空闲中</el-tag>
									<el-tag type="warning" effect="dark" v-else-if="form.status=='1'">使用中</el-tag>
									<el-tag type="danger" effect="dark" v-else-if="form.status=='2'">维修中</el-tag>
									<el-tag type="info" effect="dark" v-else-if="form.status=='3'">已报废</el-tag>
								</el-form-item>
							</el-col>
						</el-row>
						<el-form-item label="备注说明">
							<div v-html="form.remark"></div>
						</el-form-item>
						<el-form-item label="相关附件" v-if="form.attachId!=''">
							<attach-menu :attachIds="form.attachId" :roleFlag="3" :preview="true" ></attach-menu>
						</el-form-item>
					</el-form>
				</el-form>

				<el-footer style="text-align: center;">
					<el-button @click="visible=false">关闭</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-drawer>
</template>

<script>
import AttachMenu from '@/views/module/attachMenu'

export default {
	emits: ['success', 'closed'],
	components: {
		AttachMenu,
	},
	data() {
		return {
			loading: false,
			form: {
				assetsId: '',
				sortNo: 0,
				assetsName: '',
				assetsCode: '',
				ownDeptName:'',
				sortId: '',
				brand: '',
				model: '',
				storageName:'',
				depreciation: '1',
				purchasePrice: 0,
				purchaseTime: '',
				sortName:'',
				unit: '',
				status:'',
				unitName:'',
				attachId: '',
				ownDept: '',
				remark: '',
			},
			model: "rece",
			visible: false,
			isSaveing: false,
		}
	},
	mounted() {

	},
	methods: {
		getDepreciation(v){
			if(v=="0")
			{
				return "平均年限法";
			}else if(v=="1")
			{
				return "工作量折旧法"
			}else if(v=="2")
			{
				return "双倍余额递减法"
			}else if(v=="3")
			{
				return "年数总合法"
			}
		},
		//显示
		open(model) {
			this.model = model;
			this.visible = true;
			return this;
		},
		async getFixedAssetsById()
		{
			var res = await this.$API.office.fixed.getFixedAssetsById.get({assetsId:this.form.assetsId});
			if(res.code==200)
			{
				this.form = res.data;
			}
		},
		//表单注入数据
		setData(data) {
			this.form.assetsId = data.assetsId
			this.getFixedAssetsById();
		},
	}
}
</script>

<style>
</style>
